#!/bin/sh -v

pwd

mkdir -p target
#  坑~ 复制 jar包 到 当前的target/
cp -f ../"$JOB_NAME"@2/target/"$APP_NAME"-"$APP_VERSION".jar  target/"$APP_NAME"-"$APP_VERSION".jar

docker stop "$(docker ps|grep $APP_NAME|awk '{print $1}')"

docker rm "$(docker ps -a |grep $APP_NAME| awk '{print $1}')"

docker rmi "$(docker images |grep $APP_NAME| awk '{print $3}')"

docker build -t "$APP_NAME":"$BUILD_NUMBER" .

docker run -d --name "$APP_NAME" -p 8888:8888 -v /var/logs:/app-logs "$APP_NAME":"$BUILD_NUMBER"
